$(document).ready(function () {
    $("#login").click(function () {

        var uid = $("#uid").val();
        var password = $("#password").val();

        //checking for blank fields
        if (uid === '' || password === '') {
            $('input[type="text"],input[type="password"]').css({
                "border": "2px solid red",
                "box-shadow": "0 0 3px red"
            });

            alert("Please fill all fields...!!!!!!");
            return false;
        } else {
            if (password.length < 8) {
                $('input[type="password"]').css({
                    "border": "2px solid red",
                    "box-shadow": "0 0 3px red"
                });
                alert('password must be of minimum 8 characters');
                $('#password').val('');
                return false;
            }else {
                setName($('#uid').val());
            }
        }


    });

    //设置聚焦样式
    $("input").focus(function () {
        $(this).css({
            "background-color": "#cccccc",
            "color": "#000"
        });
    });

    //设置失焦的样式
    $("input").blur(function () {
        $(this).css({
            "background-color": "#ffffff",
            "color": " #4f4f4f"
        });
    });
});

//将名字信息存入sessionStorage
function setName(name) {
    if (Storage) {
        localStorage.setItem("username", name);
    }
}

//从sessionStorage中获取用户名
function getName() {
    if (Storage) {
        return localStorage.getItem("username");
    }
}